package com.zhangyu.eat.login.presenter;

import android.os.Handler;

import com.zhangyu.eat.login.model.LoginBiz;
import com.zhangyu.eat.login.model.OnLoginListener;
import com.zhangyu.eat.login.model.ToRegisterListenter;
import com.zhangyu.eat.login.view.ILoginView;


/**
 * Created by SoSho on 2016/10/14.
 */

public class Loginpresenter {
    private LoginBiz mLoginbiz;
    private ILoginView mView;

    public Loginpresenter(ILoginView view) {
        mLoginbiz = new LoginBiz();
        this.mView = view;
    }

    private Handler mhandler = new Handler();

    public void login() {
        mLoginbiz.login(mView.getUserName(), mView.getPassWord(), new OnLoginListener() {
            @Override
            public void loginSucceed() {
                mView.toSucceedActivity();
            }

            @Override
            public void loginFailed() {
                mView.showLoginFailedView();
            }

        });
    }

    public void register() {
        mLoginbiz.register(new ToRegisterListenter() {
            @Override
            public void toRegistered() {
                mView.toRegisterActivity();
            }
        });
    }

    public void reset() {
        mView.resetMsg();
    }
}
